//
//  SetupViewController.m
//  Wtracker
//
//  Created by Anna on 6/28/10.
//

#import "SetupViewController.h"


@implementation SetupViewController

@synthesize  nameTF, emailTF, defEmailTF ; //textfields
@synthesize unitPicker, unitLabel, dataSource; //uipickers


- (void)viewDidLoad {
    [super viewDidLoad];

	self.navigationItem.title = @"Your Settings";
	self.dataSource = [NSArray arrayWithObjects:
					   @"Pounds (lbs)", @"Kilograms (kgs)",
					   nil];	
	
	[unitPicker reloadAllComponents];
	[unitPicker selectRow:0 inComponent:0 animated:NO];
	unitLabel.text = [dataSource objectAtIndex:0];
	

}

- (IBAction)saveSettings{
	NSLog(@"save the settings");
	[self.navigationController popViewControllerAnimated:YES];

}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
	[textField resignFirstResponder];
	return YES;
}


#pragma mark -
#pragma mark UIPickerViewDataSource Methods

- (NSInteger) numberOfComponentsInPickerView: (UIPickerView *) pickerView {
	return 1;
}
- (NSInteger) pickerView: (UIPickerView *) pickerView numberOfRowsInComponent: (NSInteger) component {
	return [dataSource count];
}

#pragma mark -
#pragma mark UIPickerViewDelegate Methods

- (NSString *) pickerView: (UIPickerView *) pickerView
			  titleForRow: (NSInteger) row forComponent: (NSInteger) component {
	return [dataSource objectAtIndex:row];
}
- (void) pickerView: (UIPickerView *) pickerView
	   didSelectRow: (NSInteger) row inComponent: (NSInteger) component {
	unitLabel.text = [dataSource objectAtIndex:row];
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
}


- (void)viewDidUnload {
    [super viewDidUnload];

}


- (void)dealloc {
	[nameTF release];
	[emailTF release];
	[defEmailTF release];
	[dataSource release];
	[unitPicker release];
	[unitLabel release];
    [super dealloc];
}


@end
